# Import Module
from tkinter import *



# create root window
root = Tk()

# root window title and dimension
root.title("tkinter学习")
# Set geometry(widthxheight)
root.geometry('800x600')
# 定义关闭窗口的回调函数
def on_closing():
    print("窗口关闭")
    # 销毁窗口,不写这行的话，窗口就关不了   
    root.destroy()
    # 退出Tkinter事件循环,即退出程序
    root.quit()

root.protocol("WM_DELETE_WINDOW", on_closing)




# Execute Tkinter
root.mainloop()
